package com.briup.web;

import com.briup.util.ResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;

@RestController
@Api(tags = "京东云平台")
public class JDContraller {
    @GetMapping("/Weather")
    @ApiOperation(value = "天气预报")
    @ApiImplicitParams({@ApiImplicitParam(name="city",value = "城市名称，例如北京",required = true)})
    public ResponseUtil Weather(String city){
//
        System.out.println(city);

        String url ="https://way.jd.com/jisuapi/weather?city={city}&appkey=51d354810b136f5dc9a01a4260e4c6c3";
        RestTemplate restTemplate =new RestTemplate();
        ResponseEntity responseEntity =restTemplate.getForEntity(url,String.class,city);
        String str = (String) responseEntity.getBody();
        ResponseUtil responseUtil = ResponseUtil.ok(str);
        return responseUtil;
    }
}
